/******************************************************************************

	COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2010.

	This file is part of the Maxsi Library.

	Maxsi Library is free software: you can redistribute it and/or modify it
	under the terms of the GNU Lesser General Public License as published by
	the Free Software Foundation, either version 3 of the License, or (at your
	option) any later version.

	Maxsi Library is distributed in the hope that it will be useful, but
	WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
	or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
	License for more details.

	You should have received a copy of the GNU Lesser General Public License
	along with Maxsi Library. If not, see <http://www.gnu.org/licenses/>.

	Maxsi Library
	A powerful Cross-Platform C++ General Purpose Library that allows you to
	efficiently create high-performance and reliable applications.

	MaxsiWindowSystem.cpp
	A powerful UI System abstraction layer that allows the same UI code to run
	on any platform that implements a Maxsi Window System.

******************************************************************************/

#include "MaxsiLibrary.h"

BeginMaxsiNamespace

MaxsiError MaxsiWindow::OnEvent(MaxsiWindowEvent* Event)
{
	if ( Event->Type == MAXSI_EVENT_GET_TEXT )
	{
		Event->Attachment		=	(BYTE*)GetText();
		Event->AttachmentSize	=	MESTRSIZE((MESTR*)Event->Attachment);
		Event->AttachmentFlags	|=	MAXSI_ATTACHMENT_TEXT;
		return MAXSI_ERROR_SUCCESS;
	}
	else if ( Event->Type == MAXSI_EVENT_SET_TEXT )
	{
		SetText((MESTR*)Event->Attachment);
		return MAXSI_ERROR_SUCCESS;
	}
	else if ( Event->Type == MAXSI_EVENT_GET_PROGRESS )
	{
		Event->LParam		=	(int)(CurrentProgress*100.0f);
		Event->RParam		=	(int)CurrentProgressType;
		return MAXSI_ERROR_SUCCESS;
	}
	else if ( Event->Type == MAXSI_EVENT_SET_PROGRESS )
	{		
		return SetProgress((float)Event->LParam/100.0f, (int)Event->RParam);
	}

	return MAXSI_ERROR_UNHANDLED_EVENT;
}

EndMaxsiNamespace
